package com.itheima.stock.controller;

import com.itheima.stock.common.domain.InnerMarketDomain;
import com.itheima.stock.common.domain.Stock4EvrDayDomain;
import com.itheima.stock.common.domain.Stock4MinuteDomain;
import com.itheima.stock.common.domain.StockUpdownDomain;
import com.itheima.stock.pojo.StockBlockRtInfo;
import com.itheima.stock.service.StockUserService;
import com.itheima.stock.vo.req.LoginReqVo;
import com.itheima.stock.vo.resp.LoginRespVo;
import com.itheima.stock.vo.resp.PageResult;
import com.itheima.stock.vo.resp.R;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.util.List;
import java.util.Map;


@RestController
@RequestMapping("/api")
public class UserController {
    @Autowired
    private StockUserService stockUserService;

    @PostMapping("/login")
    public R<LoginRespVo> login(@RequestBody LoginReqVo reqVo){
        return stockUserService.login(reqVo);
    }
    @GetMapping("/captcha")
    public R<Map<String,String>> captcha(){
        return stockUserService.captcha();
    }
    @GetMapping("/quot/index/all")
    public R<List<InnerMarketDomain>> stockmarket(){
        return stockUserService.stockmarket();
    }
    @GetMapping("/quot/sector/all")
    public R<List<StockBlockRtInfo>> stockBlockRtInfo(){
        return stockUserService.stockBlockRtInfo();
    }
    @GetMapping("/quot/stock/increase")
    public R<List<StockUpdownDomain>> increase(){
        return stockUserService.increase();
    }
    @GetMapping("/quot/stock/all")
    public R<PageResult<StockUpdownDomain>> stockAll(Integer page,Integer pageSize){
        return stockUserService.stockAll(page,pageSize);

    }
    @GetMapping("/quot/stock/updown/count")
    public R<Map<String,List<Map<String,String>>>>  stockUpdownCount(){
        return stockUserService.stockUpdownCount();
    }
    @GetMapping("/quot/stock/export")
    public void export(HttpServletResponse response,Integer page, Integer pageSize) throws IOException {
        stockUserService.export(response,page,pageSize);
    }
    @GetMapping("/quot/stock/tradevol")
    public R<Map<String,List<Map<String,String>>>> tradevol(){
        return stockUserService.tradevol();
    }
    @GetMapping("/quot/stock/updown")
    public R<Map<Map<String,String>,Map<String,List<Map<String,String>>>>> updown(){
        return stockUserService.updown();
    }
    @GetMapping("quot/stock/screen/time-sharing")
    public R<List<Stock4MinuteDomain>> timeSharing( String code){
        System.out.println("stockCode = " + code);
        return stockUserService.timeSharing(code);
    }
    @GetMapping("/quot/stock/screen/dkline")
    public R<List<Stock4EvrDayDomain>> dkline(String code){
        return stockUserService.dkline(code);
    }


}